﻿using UnityEngine;
using System.Collections;

public class Person : MonoBehaviour {
	public static float distanceTraveled;
	public float Speed = 5f;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		if (transform.localPosition.x > 40)
						Speed = -2;
		else if (Speed == -2 && transform.localPosition.x < 30)
			Speed = 5;
		transform.Translate(Speed * Time.deltaTime, 0f, 0f);
		distanceTraveled = transform.localPosition.x;
	}
}
